﻿<mvvmHelpers:SystemMenuWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ulsDeobfuscator="clr-namespace:ULSDeobfuscator"
    xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
    xmlns:mvvmHelpers="clr-namespace:Elca.MvvmHelpers"
    xmlns:microsoftWindowsThemes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Royale"
    xmlns:markup="clr-namespace:ULSDeobfuscator.MVVM.Markup"
    xmlns:system="clr-namespace:System;assembly=mscorlib"
    xmlns:themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" 
    x:Class="ULSDeobfuscator.MainWindow"
    mc:Ignorable="d" 
    d:DataContext="{d:DesignInstance Type={x:Type ulsDeobfuscator:MainWindowViewModel}}"
    Title="{Binding WindowTitle}"
    x:Name="RibbonWindow"
    ResizeMode="CanResizeWithGrip"
    d:DesignHeight="940"
    d:DesignWidth="1950"
    mvvmHelpers:ViewModelCreator.DataContext="ulsDeobfuscator.MainWindowViewModel"
    Left="{Binding WindowLeft, Mode=TwoWay}"
    Top="{Binding WindowTop, Mode=TwoWay}"
    WindowState="{Binding WindowState, Mode=TwoWay}"
    mvvmHelpers:LifetimeEvent.Close="{Binding CloseCommand}"
    mvvmHelpers:LifetimeEvent.Loaded ="{Binding LoadCommand}"
    mvvmHelpers:DropHelper.DropHandler="{Binding}"
    SnapsToDevicePixels="True"
    mvvmHelpers:PreviewKeyHelper.EscapeCommand="{Binding CancelOperationCommand}"
    >

    <mvvmHelpers:SystemMenuWindow.Resources>
        <mvvmHelpers:WidthConverter x:Key="WidthConverter" />

        <Style x:Key="LogGridViewColumnHeader"
               TargetType="{x:Type GridViewColumnHeader}" >
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        </Style>

        <CollectionViewSource x:Key="ProcessesListSource"
                              Source="{Binding ProcessColumn.FiltersList}">
            <CollectionViewSource.SortDescriptions>
                <componentModel:SortDescription PropertyName="ItemName" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>

        <CollectionViewSource x:Key="AreasListSource"
                              Source="{Binding AreaColumn.FiltersList}">
            <CollectionViewSource.SortDescriptions>
                <componentModel:SortDescription PropertyName="ItemName" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>

        <CollectionViewSource x:Key="CategoriesListSource"
                              Source="{Binding CategoryColumn.FiltersList}">
            <CollectionViewSource.SortDescriptions>
                <componentModel:SortDescription PropertyName="ItemName" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>

        <CollectionViewSource x:Key="LevelsListSource"
                              Source="{Binding LevelColumn.FiltersList}">
            <CollectionViewSource.SortDescriptions>
                <componentModel:SortDescription PropertyName="ItemName" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>

        <CollectionViewSource x:Key="EventsListSource"
                              Source="{Binding EventColumn.FiltersList}">
            <CollectionViewSource.SortDescriptions>
                <componentModel:SortDescription PropertyName="ItemName" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>

        <CollectionViewSource x:Key="RecentMessagesSource"
                              Source="{Binding RecentSearchMessages}"/>

        <CollectionViewSource x:Key="RecentFiltersSource"
                              Source="{Binding RecentSearchFilters}"/>

        <!-- The following is a copy of the button resource template, the modifications are near comments below -->
        <Style x:Key="ButtonFocusVisual">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Rectangle Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1" Margin="2" SnapsToDevicePixels="true"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="ButtonNoBorderStyle" TargetType="{x:Type Button}">
            <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
            <Setter Property="Background" Value="Transparent"/>
            <!-- 
			<Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
			<Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
			-->
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Padding" Value="1"/>
            <Setter Property="Margin" Value="5" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <microsoftWindowsThemes:ButtonChrome x:Name="Chrome" 
        					SnapsToDevicePixels="true" 
        					BorderBrush="{TemplateBinding BorderBrush}" 
        					RenderDefaulted="{TemplateBinding IsDefaulted}" 
        					RenderMouseOver="{TemplateBinding IsMouseOver}" 
        					RenderPressed="{TemplateBinding IsPressed}" 
        					HorizontalAlignment="Left" >
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
        						Margin="{TemplateBinding Padding}" 
        						VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
        						SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
        						RecognizesAccessKey="True"/>
                        </microsoftWindowsThemes:ButtonChrome>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsKeyboardFocused" Value="true">
                                <Setter Property="RenderDefaulted" TargetName="Chrome" Value="true"/>
                            </Trigger>
                            <Trigger Property="ToggleButton.IsChecked" Value="true">
                                <Setter Property="RenderPressed" TargetName="Chrome" Value="true"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="#ADADAD"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- ListView and associated struff re-created by Blend, in order to change the template of the vertical scroll bar, were we add the annotation information -->
        <SolidColorBrush x:Key="ListBorder" Color="#828790"/>
        <Style x:Key="LogListViewStyle" TargetType="{x:Type ListView}">
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
            <Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Foreground" Value="#FF042271"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListView}">
                        <themes:ListBoxChrome x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderFocused="{TemplateBinding IsKeyboardFocusWithin}" SnapsToDevicePixels="true">
                            <ScrollViewer Padding="{TemplateBinding Padding}" Style="{DynamicResource LogScrollViewerStyle}">
                                <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </ScrollViewer>
                        </themes:ListBoxChrome>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsGrouping" Value="true">
                                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="LogScrollViewerStyle" TargetType="{x:Type ScrollViewer}">
            <Setter Property="Focusable" Value="False"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ScrollViewer}">
                        <Grid Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <DockPanel Margin="{TemplateBinding Padding}">
                                <ScrollViewer DockPanel.Dock="Top" Focusable="False" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
                                    <GridViewHeaderRowPresenter AllowsColumnReorder="{Binding TemplatedParent.View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}" 
                                                                ColumnHeaderContainerStyle="{Binding TemplatedParent.View.ColumnHeaderContainerStyle, RelativeSource={RelativeSource TemplatedParent}}" 
                                                                ColumnHeaderToolTip="{Binding TemplatedParent.View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}" 
                                                                ColumnHeaderContextMenu="{Binding TemplatedParent.View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}" 
                                                                ColumnHeaderTemplate="{Binding TemplatedParent.View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}" 
                                                                Columns="{Binding TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}" 
                                                                Margin="2,0" 
                                                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                </ScrollViewer>
                                <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" KeyboardNavigation.DirectionalNavigation="Local" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </DockPanel>
                            <ScrollBar x:Name="PART_HorizontalScrollBar" Cursor="Arrow" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
                            <!-- change to the standard template: 
                                 - scroll bar is always visible so that annotation UI is always present 
                                 - added the drawing of annotations markers
                            -->
                            <ScrollBar x:Name="PART_VerticalScrollBar" 
                                       Cursor="Arrow" 
                                       Grid.Column="1" 
                                       Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" 
                                       Orientation="Vertical" 
                                       Visibility="Visible" 
                                       Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" 
                                       ViewportSize="{TemplateBinding ViewportHeight}" 
                                       Style="{DynamicResource LogVerticalScrollBarStyle}" />

                            <DockPanel Background="{Binding Background, ElementName=PART_VerticalScrollBar}" Grid.Column="1" LastChildFill="False" Grid.Row="1">
                                <Rectangle DockPanel.Dock="Left" Fill="White" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Width="1"/>
                                <Rectangle DockPanel.Dock="Top" Fill="White" Height="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
                            </DockPanel>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <LinearGradientBrush x:Key="VerticalScrollBarBackground" EndPoint="1,0" StartPoint="0,0">
            <GradientStop Color="#E1E1E1" Offset="0"/>
            <GradientStop Color="#EDEDED" Offset="0.20"/>
            <GradientStop Color="#EDEDED" Offset="0.80"/>
            <GradientStop Color="#E3E3E3" Offset="1"/>
        </LinearGradientBrush>
        <SolidColorBrush x:Key="ScrollBarDisabledBackground" Color="#F4F4F4"/>
        <Style x:Key="ScrollBarButton" TargetType="{x:Type RepeatButton}">
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="Focusable" Value="false"/>
            <Setter Property="IsTabStop" Value="false"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RepeatButton}">
                        <themes:ScrollChrome x:Name="Chrome" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" SnapsToDevicePixels="true" themes:ScrollChrome.ScrollGlyph="{TemplateBinding themes:ScrollChrome.ScrollGlyph}"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="VerticalScrollBarPageButton" TargetType="{x:Type RepeatButton}">
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Focusable" Value="false"/>
            <Setter Property="IsTabStop" Value="false"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RepeatButton}">
                        <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="IsTabStop" Value="false"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Thumb}">
                        <themes:ScrollChrome x:Name="Chrome" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsDragging}" SnapsToDevicePixels="true" themes:ScrollChrome.ScrollGlyph="{TemplateBinding themes:ScrollChrome.ScrollGlyph}"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <LinearGradientBrush x:Key="HorizontalScrollBarBackground" EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#E1E1E1" Offset="0"/>
            <GradientStop Color="#EDEDED" Offset="0.20"/>
            <GradientStop Color="#EDEDED" Offset="0.80"/>
            <GradientStop Color="#E3E3E3" Offset="1"/>
        </LinearGradientBrush>
        <Style x:Key="HorizontalScrollBarPageButton" TargetType="{x:Type RepeatButton}">
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Focusable" Value="false"/>
            <Setter Property="IsTabStop" Value="false"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RepeatButton}">
                        <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="LogVerticalScrollBarStyle" TargetType="{x:Type ScrollBar}">
            <Setter Property="Background" Value="{StaticResource VerticalScrollBarBackground}"/>
            <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
            <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="Width" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
            <Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ScrollBar}">
                        <Grid x:Name="Bg" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                            <Grid.RowDefinitions>
                                <RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}"/>
                                <RowDefinition Height="0.00001*"/>
                                <RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}"/>
                            </Grid.RowDefinitions>
                            <RepeatButton Command="{x:Static ScrollBar.LineUpCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{StaticResource ScrollBarButton}" themes:ScrollChrome.ScrollGlyph="UpArrow"/>
                            
                            <!-- change to the standard template: 
                                 - added the drawing of annotations markers
                            -->

                            <Track x:Name="PART_Track" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}" Grid.Row="1">
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Command="{x:Static ScrollBar.PageUpCommand}" Style="{StaticResource VerticalScrollBarPageButton}"/>
                                </Track.DecreaseRepeatButton>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" Style="{StaticResource VerticalScrollBarPageButton}"/>
                                </Track.IncreaseRepeatButton>
                                <Track.Thumb>
                                    <Thumb Style="{StaticResource ScrollBarThumb}" themes:ScrollChrome.ScrollGlyph="VerticalGripper"/>
                                </Track.Thumb>
                            </Track>

                            <mvvmHelpers:VerticalDrawing Grid.Row="1"
                                                         ItemsSource="{Binding Annotations}"
                                                         IsEnabled="True"
                                                         Command="{Binding JumpToEntryCommand}" 
                                                         EditCommand="{Binding UpdateAnnotationCommandExternal}"
                                                         DeleteCommand="{Binding DeleteAnnotationCommandExternal}" />

                            <RepeatButton Command="{x:Static ScrollBar.LineDownCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Grid.Row="2" Style="{StaticResource ScrollBarButton}" themes:ScrollChrome.ScrollGlyph="DownArrow"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBarDisabledBackground}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="Orientation" Value="Horizontal">
                    <Setter Property="Width" Value="Auto"/>
                    <Setter Property="MinWidth" Value="0"/>
                    <Setter Property="Height" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
                    <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
                    <Setter Property="Background" Value="{StaticResource HorizontalScrollBarBackground}"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ScrollBar}">
                                <Grid x:Name="Bg" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
                                        <ColumnDefinition Width="0.00001*"/>
                                        <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
                                    </Grid.ColumnDefinitions>
                                    <RepeatButton Command="{x:Static ScrollBar.LineLeftCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{StaticResource ScrollBarButton}" themes:ScrollChrome.ScrollGlyph="LeftArrow"/>
                                    <Track x:Name="PART_Track" Grid.Column="1" IsEnabled="{TemplateBinding IsMouseOver}">
                                        <Track.DecreaseRepeatButton>
                                            <RepeatButton Command="{x:Static ScrollBar.PageLeftCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
                                        </Track.DecreaseRepeatButton>
                                        <Track.IncreaseRepeatButton>
                                            <RepeatButton Command="{x:Static ScrollBar.PageRightCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
                                        </Track.IncreaseRepeatButton>
                                        <Track.Thumb>
                                            <Thumb Style="{StaticResource ScrollBarThumb}" themes:ScrollChrome.ScrollGlyph="HorizontalGripper"/>
                                        </Track.Thumb>
                                    </Track>
                                    <RepeatButton Grid.Column="2" Command="{x:Static ScrollBar.LineRightCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{StaticResource ScrollBarButton}" themes:ScrollChrome.ScrollGlyph="RightArrow"/>
                                </Grid>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsEnabled" Value="false">
                                        <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBarDisabledBackground}"/>
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
        <!-- end of re-created ListView template -->

    </mvvmHelpers:SystemMenuWindow.Resources>

    <mvvmHelpers:InputBinder.Bindings>
        <mvvmHelpers:KeyBinding Key="F"
              Modifiers="Control" 
              Command="{Binding FocusToMessageSearchBoxCommand}" />
        <mvvmHelpers:KeyBinding Key="F3"
              Command="{Binding MessageSearchCommand}" />
        <mvvmHelpers:KeyBinding Key="F3"
              Modifiers="Shift" 
              Command="{Binding MessageSearchPreviousCommand}" />
        <mvvmHelpers:KeyBinding Key="Escape"
              Modifiers="Shift" 
              Command="{Binding MessageSearchPreviousCommand}" />
    </mvvmHelpers:InputBinder.Bindings>

    <DockPanel mvvmHelpers:SizeObserver.Observe="True"
		mvvmHelpers:SizeObserver.ObservedWidth="{Binding TimelineWidth, Mode=TwoWay}"
        >

        <Grid DockPanel.Dock="Top"
			mvvmHelpers:ColumnSizeObserver.Widths="{Binding ToolbarColumnWidths}"
			mvvmHelpers:ColumnSizeObserver.IsWidthReady="{Binding IsToolbarColumnWidthReady, Mode=TwoWay}"
              >

            <Grid.Resources>
                <SolidColorBrush x:Key="HeaderColor" Color="#9E9E9E" />
                <SolidColorBrush x:Key="SeparatorColor" Color="#B9C9DA" />
            </Grid.Resources>

            <Grid.Background>
                <LinearGradientBrush StartPoint="0, 0" EndPoint="0,1">
                    <GradientStop Color="#FAFBFD" Offset="0" />
                    <GradientStop Color="#E3ECF6" Offset=".5" />
                    <GradientStop Color="#E1EAF6" Offset=".75" />
                    <GradientStop Color="#E3ECF6" Offset="1" />
                </LinearGradientBrush>
            </Grid.Background>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="5" />

                <!-- 2: Button for Time Interval -->
                <ColumnDefinition Width="Auto" />
                <!-- 3: Real Time Interval -->
                <ColumnDefinition Width="Auto" />

                <ColumnDefinition Width="5" />
                <!-- 5: Button for Show Columns -->
                <ColumnDefinition Width="Auto" />
                <!-- 6: Real Show Columns -->
                <ColumnDefinition Width="Auto" />

                <ColumnDefinition Width="5" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="5" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="5" />
                <!-- 12: Button for Others -->
                <ColumnDefinition Width="Auto" />
                <!-- 13: Real Others -->
                <ColumnDefinition Width="Auto" />

                <ColumnDefinition Width="5" />
                <!-- 15: Annotations -->
                <ColumnDefinition Width="Auto" />

            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <!-- This margin seems to be enough to add some bottom space to all footers -->
            <TextBlock Grid.Row="1"
				Margin="0,0,0,2"
				HorizontalAlignment="Center"
				Foreground="{StaticResource HeaderColor}"
				Text="File" />

            <StackPanel Orientation="Horizontal">

                <Button Command="{Binding OpenCommand, Mode=OneTime}"
					Style="{StaticResource ButtonNoBorderStyle}" >

                    <StackPanel>
                        <Image Source="Images/Open32.png"
							Margin="3"/>
                        <TextBlock Text="Open"
							HorizontalAlignment="Center"/>
                    </StackPanel>
                </Button>

                <Button Command="{Binding SaveCommand, Mode=OneTime}"
					Style="{StaticResource ButtonNoBorderStyle}" >

                    <StackPanel>
                        <Image Source="Images/Save32.png"
							Margin="3"/>
                        <TextBlock Text="Save"
							HorizontalAlignment="Center"/>
                    </StackPanel>
                </Button>
            </StackPanel>

            <Line Grid.Column="1" Grid.RowSpan="2"
				X1="2" Y1="0"
				X2="2" Y2="80"
				Stroke="{StaticResource SeparatorColor}" />
            <Line Grid.Column="4" Grid.RowSpan="2"
				X1="2" Y1="0"
				X2="2" Y2="80"
				Stroke="{StaticResource SeparatorColor}" />
            <Line Grid.Column="7" Grid.RowSpan="2"
				X1="2" Y1="0"
				X2="2" Y2="80"
				Stroke="{StaticResource SeparatorColor}" />
            <Line Grid.Column="9" Grid.RowSpan="2"
				X1="2" Y1="0"
				X2="2" Y2="80"
				Stroke="{StaticResource SeparatorColor}" />
            <Line Grid.Column="11" Grid.RowSpan="2"
				X1="2" Y1="0"
				X2="2" Y2="80"
				Stroke="{StaticResource SeparatorColor}" />
            <Line Grid.Column="14" Grid.RowSpan="2"
				X1="2" Y1="0"
				X2="2" Y2="80"
				Stroke="{StaticResource SeparatorColor}" />

            <!-- Time Start: button + real stuff -->

            <!-- Must set an explicit width: in the VM, we set the width explicitly of the containing grid column => 
                 the button adapts itself, truncates its text, then rotates and does not realize that it now has enough room to display the full text -->
            <Button Grid.Column="2"
				Height="25"
				Width="70"
				Margin="5,0,5,0"
				x:Name="TimeStart" 
				Command="{Binding DisplayTimeStartPopupCommand, Mode=OneTime}" Content="Time">
                <Button.LayoutTransform>
                    <RotateTransform Angle="-90" />
                </Button.LayoutTransform>
            </Button>

            <!-- There may be a simpler way than repeating the whole grid of Time Start, but it certainly is easier than dynamically removing the grid from the toolbar and setting it as the child of the Border below -->
            <Popup PlacementTarget="{Binding ElementName=TimeStart}" 
				Placement="Right"
				StaysOpen="False"
				IsOpen="{Binding IsShowingTimeStartPopup, Mode=TwoWay}">
                <Border BorderThickness="1"
					Background="White" >
                    <Grid Margin="5">

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="3" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="3" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <TextBlock Text="Log available from:"
							Margin="2"/>
                        <TextBlock Text=" to: "
							Grid.Column="2"
							Margin="2"/>

                        <TextBlock Text="Show around:"
							Grid.Row="2"
							Margin="2" />

                        <TextBlock Text="{Binding DisplayedMinAvailableLogDate}"
							Grid.Column="1"
							Margin="2"/>
                        <TextBlock Text="{Binding DisplayedMaxAvailableLogDate}"
							Grid.Column="3" Grid.ColumnSpan="2"
							Margin="2"/>

                        <TextBox Grid.Row="2" Grid.Column="1"
							MinWidth="100"
							Text="{Binding ChosenMiddleLogTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                        <TextBlock Text=" +/- "
							Grid.Row="2" Grid.Column="2"
							Margin="2"/>
                        <TextBox Text="{Binding AroundTimeQuantity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
							Grid.Row="2" Grid.Column="3"
							Margin="0,0,5,0"
							Width="30" />
                        <ComboBox IsEditable="False"
							Grid.Row="2" Grid.Column="4"
							x:Name="IntervalComboBox2"
							SelectedIndex="{Binding AroundTimeUnit, Mode=TwoWay}">
                            <ComboBoxItem Content="seconds"/>
                            <ComboBoxItem Content="minutes"/>
                            <ComboBoxItem Content="hours"/>
                        </ComboBox>

                        <Button Grid.Row="4"
							Content="Show all"
							Command="{Binding ShowFullTimeIntervalCommand}" />
                        <Button Grid.Row="4" Grid.ColumnSpan="3" Grid.Column="1"
							Padding="5,0,5,0"
							Content="Show selected timeline"
							HorizontalAlignment="Center"
							Command="{Binding ApplyTimelineSelectionFilterCommand}" />

                        <Button Grid.Row="4" Grid.Column="4"
							Content="Apply Now"
							HorizontalAlignment="Right"
							Width="{Binding ActualWidth, ElementName=IntervalComboBox2}"
							Command="{Binding ApplyTimeIntervalCommand}" />
                    </Grid>
                </Border>
            </Popup>


            <TextBlock Grid.Row="1" Grid.Column="3"
				HorizontalAlignment="Center"
				Foreground="{StaticResource HeaderColor}"
				Text="Time Interval" />

            <Grid Grid.Column="3"
				Margin="5"
                  >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="3" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="3" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <TextBlock Text="Log available from:"
					Margin="2"/>
                <TextBlock Text=" to: "
					Grid.Column="2"
					Margin="2"/>

                <TextBlock Text="Show around:"
					Grid.Row="2"
					Margin="2" />

                <TextBlock Text="{Binding DisplayedMinAvailableLogDate}"
					Grid.Column="1"
					Margin="2"/>
                <TextBlock Text="{Binding DisplayedMaxAvailableLogDate}"
					Grid.Column="3" Grid.ColumnSpan="2"
					Margin="2"/>

                <TextBox Grid.Row="2" Grid.Column="1"
					MinWidth="100"
					Text="{Binding ChosenMiddleLogTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                <TextBlock Text=" +/- "
					Grid.Row="2" Grid.Column="2"
					Margin="2"/>
                <TextBox Text="{Binding AroundTimeQuantity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
					Grid.Row="2" Grid.Column="3"
					Margin="0,0,5,0"
					Width="30" />
                <ComboBox IsEditable="False"
					Grid.Row="2" Grid.Column="4"
					x:Name="IntervalComboBox"
					SelectedIndex="{Binding AroundTimeUnit, Mode=TwoWay}">
                    <ComboBoxItem Content="seconds"/>
                    <ComboBoxItem Content="minutes"/>
                    <ComboBoxItem Content="hours"/>
                </ComboBox>

                <Button Grid.Row="4"
					Content="Show all"
					Command="{Binding ShowFullTimeIntervalCommand}" />
                <Button Grid.Row="4" Grid.ColumnSpan="3" Grid.Column="1"
					Content="Show selected timeline"
					Padding="5,0,5,0"
					HorizontalAlignment="Center"
					Command="{Binding ApplyTimelineSelectionFilterCommand}" />

                <Button Grid.Row="4" Grid.Column="4"
					Width="{Binding ActualWidth, ElementName=IntervalComboBox}"
					Content="Apply Now"
					HorizontalAlignment="Right"
					Command="{Binding ApplyTimeIntervalCommand}" />
            </Grid>

            <!-- Show columns: button + full -->
            <Button Grid.Column="5"
				Height="25"
				Width="70"
				Margin="5,0,5,0"
				x:Name="TimeShowColumns" 
				Command="{Binding DisplayShowColumnsPopupCommand, Mode=OneTime}" Content="Columns">
                <Button.LayoutTransform>
                    <RotateTransform Angle="-90" />
                </Button.LayoutTransform>
            </Button>

            <!-- There may be a simpler way than repeating the whole grid of Time Start, but it certainly is easier than dynamically removing the grid from the toolbar and setting it as the child of the Border below -->
            <Popup PlacementTarget="{Binding ElementName=TimeShowColumns}" 
				Placement="Right"
				StaysOpen="False"
				IsOpen="{Binding IsShowingShowColumnsPopup, Mode=TwoWay}">
                <Border BorderThickness="1"
					Background="White" >

                    <Grid Margin="5">

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <CheckBox IsChecked="{Binding IsDateShown, Mode=TwoWay}"
							Margin="2"
							Content="Date" />
                        <CheckBox IsChecked="{Binding IsProcessShown, Mode=TwoWay}"
							Grid.Row="1"
							Margin="2"
							Content="Process" />
                        <CheckBox IsChecked="{Binding IsThreadIdShown, Mode=TwoWay}"
							Grid.Row="2"
							Margin="2"
							Content="Thread Id" />
                        <CheckBox IsChecked="{Binding IsAreaShown, Mode=TwoWay}"
							Grid.Column="1"
							Margin="4,2,2,2"
							Content="Area" />
                        <CheckBox IsChecked="{Binding IsCategoryShown, Mode=TwoWay}"
							Grid.Row="1" Grid.Column="1"
							Margin="4,2,2,2"
							Content="Category" />
                        <CheckBox IsChecked="{Binding IsEventIdShown, Mode=TwoWay}"
							Grid.Row="2" Grid.Column="1"
							Margin="4,2,2,2"
							Content="Event ID" />
                        <CheckBox IsChecked="{Binding IsLevelShown, Mode=TwoWay}"
							Grid.Column="2"
							Margin="4,2,2,2"
							Content="Level" />
                        <CheckBox IsChecked="{Binding IsMessageShown, Mode=TwoWay}"
							Grid.Row="1" Grid.Column="2"
							Margin="4,2,2,2"
							Content="Message" />
                        <CheckBox IsChecked="{Binding IsCorrelationShown, Mode=TwoWay}"
							Grid.Row="2" Grid.Column="2"
							Margin="4,2,2,2"
							Content="Correlation ID" />

                    </Grid>

                </Border>
            </Popup>

            <TextBlock Grid.Row="1" Grid.Column="6"
				HorizontalAlignment="Center"
				Foreground="{StaticResource HeaderColor}"
				Text="Show Columns" />
            <Grid Grid.Column="6"
				Margin="5">

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <CheckBox IsChecked="{Binding IsDateShown, Mode=TwoWay}"
					Margin="2"
					Content="Date" />
                <CheckBox IsChecked="{Binding IsProcessShown, Mode=TwoWay}"
					Grid.Row="1"
					Margin="2"
					Content="Process" />
                <CheckBox IsChecked="{Binding IsThreadIdShown, Mode=TwoWay}"
					Grid.Row="2"
					Margin="2"
					Content="Thread Id" />
                <CheckBox IsChecked="{Binding IsAreaShown, Mode=TwoWay}"
					Grid.Column="1"
					Margin="4,2,2,2"
					Content="Area" />
                <CheckBox IsChecked="{Binding IsCategoryShown, Mode=TwoWay}"
					Grid.Row="1" Grid.Column="1"
					Margin="4,2,2,2"
					Content="Category" />
                <CheckBox IsChecked="{Binding IsEventIdShown, Mode=TwoWay}"
					Grid.Row="2" Grid.Column="1"
					Margin="4,2,2,2"
					Content="Event ID" />
                <CheckBox IsChecked="{Binding IsLevelShown, Mode=TwoWay}"
					Grid.Column="2"
					Margin="4,2,2,2"
					Content="Level" />
                <CheckBox IsChecked="{Binding IsMessageShown, Mode=TwoWay}"
					Grid.Row="1" Grid.Column="2"
					Margin="4,2,2,2"
					Content="Message" />
                <CheckBox IsChecked="{Binding IsCorrelationShown, Mode=TwoWay}"
					Grid.Row="2" Grid.Column="2"
					Margin="4,2,2,2"
					Content="Correlation ID" />

            </Grid>


            <TextBlock Grid.Row="1" Grid.Column="8"
				HorizontalAlignment="Center"
				Foreground="{StaticResource HeaderColor}"
				Text="Include Filters"
				ToolTip="Set simple text filter to define what log entries should be displayed"/>
            <Grid Width="200"
				Margin="5"
				Grid.Column="8">

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="2" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="3" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <TextBlock Text="Message:" 
					VerticalAlignment="Center"
					Grid.Row="1" />
                <ComboBox Grid.Row="1" Grid.Column="1"
					IsEditable="True"
					ToolTip="Enter to start filtering, Esc to remove the message filter"
					Text="{Binding MessageFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
					mvvmHelpers:PreviewKeyHelper.CarriageReturnCommand="{Binding MessageFilterCommand}"
					mvvmHelpers:PreviewKeyHelper.EscapeCommand="{Binding ClearMessageFilterCommand}"
					ItemsSource="{Binding Source={StaticResource RecentFiltersSource}}" />
                <Button Command="{Binding MessageFilterCommand}"
					Grid.Column="2" Grid.Row="1">
                    <Image Source="Images/Filter16.png" Width="16" Height="16" />
                </Button>

                <CheckBox IsChecked="{Binding IsMessageFilterRegex, Mode=TwoWay}"
					Content="Regex"
					Grid.Row="2" Grid.Column="1" />

                <TextBlock Text="Correlation ID:" 
					Grid.Row="4"
					VerticalAlignment="Center"
					Margin="0,0,2,0"
                           />
                <TextBox Text="{Binding CorrelationFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
					mvvmHelpers:PreviewKeyHelper.CarriageReturnCommand="{Binding MessageFilterCommand}"
					mvvmHelpers:PreviewKeyHelper.EscapeCommand="{Binding ClearCorrelationFilterCommand}"
					ToolTip="Enter to start filtering, Esc to remove the correlation ID filter"
					Grid.Row="4" Grid.Column="1"/>
                <Button Command="{Binding CorrelationFilterCommand}"
					Grid.Row="4" Grid.Column="2">
                    <Image Source="Images/Filter16.png" Width="16" Height="16" />
                </Button>

            </Grid>


            <TextBlock Grid.Row="1" Grid.Column="10"
				HorizontalAlignment="Center"
				Foreground="{StaticResource HeaderColor}"
				Text="Find" />

            <Grid Grid.Column="10"
				Margin="5"
				Width="200">

                <Grid.RowDefinitions>
                    <RowDefinition Height="3" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="3" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="3" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Row="1"
					Margin="0,0,3,0" 
					VerticalAlignment="Center" ><Run Text="Message:"/></TextBlock>

                <ComboBox Grid.Row="1" Grid.Column="1"
					IsEditable="True"
					mvvmHelpers:PreviewKeyHelper.CarriageReturnCommand="{Binding MessageSearchCommand}"
					mvvmHelpers:FocusHelper.IsFocused="{Binding IsMessageSearchBoxFocused, Mode=TwoWay}"
					ToolTip="Press Ctrl-F to get here; Enter to start the search"
					Text="{Binding MessageSearch, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
					ItemsSource="{Binding Source={StaticResource RecentMessagesSource}}" />
                <Button Command="{Binding MessageSearchCommand}"
					Grid.Column="2" Grid.Row="1">
                    <Image Source="Images/Find16.png" Width="16" Height="16" />
                </Button>

                <Button Command="{Binding MessageSearchPreviousCommand}"
					HorizontalAlignment="Left"
					Width="75"
					ToolTip="Press Shift-F3 to search again, backwards"
					Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="3">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="Images/Previous16.png" Width="16" Height="16" />
                        <TextBlock Margin="3,0,0,0"><Run Text="Previous"/></TextBlock>
                    </StackPanel>
                </Button>

                <Button Command="{Binding MessageSearchNextCommand}"
					HorizontalAlignment="Right"
					Width="75"
					ToolTip="Press F3 to search again"
					Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="3">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Margin="0,0,10,0"><Run Text="Next"/></TextBlock>
                        <Image Source="Images/Next16.png" Width="16" Height="16" />
                    </StackPanel>
                </Button>

                <Button Command="{Binding DeleteAllSearchMarksCommand}"
					HorizontalAlignment="Right"
					Width="75"
					ToolTip="Delete all search marks"
					Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="3">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Margin="0,0,10,0"><Run Text="Clear all"/></TextBlock>
                        <Image Source="Images/Delete16.png" Width="16" Height="16" />
                    </StackPanel>
                </Button>

            </Grid>

            <Button Grid.Column="12"
				Height="25"
				Width="70"
				Margin="5,0,5,0"
				x:Name="Others" 
				Command="{Binding DisplayShowOthersPopupCommand, Mode=OneTime}" Content="Others">
                <Button.LayoutTransform>
                    <RotateTransform Angle="-90" />
                </Button.LayoutTransform>
            </Button>
            <Popup PlacementTarget="{Binding ElementName=Others}" 
				Placement="Right"
				StaysOpen="False"
				IsOpen="{Binding IsShowingOthersPopup, Mode=TwoWay}">
                <Border BorderThickness="1"
					Background="White" >

                    <Grid Margin="5">

                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <Button Command="{Binding ManageComplexFiltersCommand}" 
							Content="{Binding ManageComplexFilterCaption}"
							ToolTip="Set expressions to define what log entries to remove from the display"
							Height="23"
							Grid.Column="1"/>

                        <CheckBox IsChecked="{Binding IsTimelineToBeShown, Mode=TwoWay}"
							Margin="0,2,0,0"
							Grid.Row="1" Grid.Column="1">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Show timeline by:" 
									VerticalAlignment="Center"/>
                                <ComboBox SelectedIndex="{Binding TimelineSelectedIndex, Mode=TwoWay}"
									Margin="5,0,0,0">
                                    <ComboBoxItem Content="Process"/>
                                    <ComboBoxItem Content="Thread ID"/>
                                    <ComboBoxItem Content="Area"/>
                                    <ComboBoxItem Content="Category"/>
                                    <ComboBoxItem Content="Level"/>
                                </ComboBox>
                            </StackPanel>
                        </CheckBox>

                        <CheckBox IsChecked="{Binding IsAutoRefresh, Mode=TwoWay}"
							Grid.Row="2" Grid.Column="1"
							ToolTip="If active, new entries are automatically appended"
							HorizontalAlignment="Left"
							VerticalAlignment="Center"
                           Content="Auto-refresh"
                           />

                        <CheckBox IsChecked="{Binding IsAutoScrolling, Mode=TwoWay}"
							IsEnabled="{Binding IsAutoScrollingEnabled}"
							Grid.Row="2" Grid.Column="1"
							ToolTip="If active, the display will scroll to the end when new entries are appended"
							HorizontalAlignment="Right"
							VerticalAlignment="Center"
                          Content="Autoscroll"
                          />

                        <Button Command="{Binding ManageColorsCommand}"
							Grid.RowSpan="3"
							Width="50"
							Style="{StaticResource ButtonNoBorderStyle}">
                            <StackPanel>
                                <Image Source="Images/Palette32.png"
									Margin="3"/>
                                <TextBlock Text="Colors"
									HorizontalAlignment="Center"/>
                            </StackPanel>

                        </Button>

                    </Grid>

                </Border>
            </Popup>

            <TextBlock Grid.Row="1" Grid.Column="13"
				HorizontalAlignment="Center"
				Foreground="{StaticResource HeaderColor}"
				Text="Others" />

            <Grid Grid.Column="13"
				Margin="5">

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Button Command="{Binding ManageComplexFiltersCommand}" 
					Content="{Binding ManageComplexFilterCaption}"
					ToolTip="Set expressions to define what log entries to remove from the display"
					Height="23"
					Grid.Column="1"/>

                <CheckBox IsChecked="{Binding IsTimelineToBeShown, Mode=TwoWay}"
					Margin="0,2,0,0"
					Grid.Row="1" Grid.Column="1">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Show timeline by:" 
							VerticalAlignment="Center"/>
                        <!-- We need to set the width because our mechanism that shows/hides parts of the toolbar only cares about the size of the parts at load time -->
                        <ComboBox SelectedIndex="{Binding TimelineSelectedIndex, Mode=TwoWay}"
							Width="80" 
							Margin="5,0,0,0">
                            <ComboBoxItem Content="Process"/>
                            <ComboBoxItem Content="Thread ID"/>
                            <ComboBoxItem Content="Area"/>
                            <ComboBoxItem Content="Category"/>
                            <ComboBoxItem Content="Level"/>
                        </ComboBox>
                    </StackPanel>
                </CheckBox>

                <CheckBox IsChecked="{Binding IsAutoRefresh, Mode=TwoWay}"
					Grid.Row="2" Grid.Column="1"
					ToolTip="If active, new entries are automatically appended"
					HorizontalAlignment="Left"
					VerticalAlignment="Center"
                           Content="Auto-refresh"
                           />

                <CheckBox IsChecked="{Binding IsAutoScrolling, Mode=TwoWay}"
					IsEnabled="{Binding IsAutoScrollingEnabled}"
					Grid.Row="2" Grid.Column="1"
					ToolTip="If active, the display will scroll to the end when new entries are appended"
					HorizontalAlignment="Right"
					VerticalAlignment="Center"
                          Content="Autoscroll"
                          />

                <Button Command="{Binding ManageColorsCommand}"
					Grid.RowSpan="3"
					Width="50"
					Style="{StaticResource ButtonNoBorderStyle}">
                    <StackPanel>
                        <Image Source="Images/Palette32.png"
							Margin="3"/>
                        <TextBlock Text="Colors"
							HorizontalAlignment="Center"/>
                    </StackPanel>

                </Button>

            </Grid>

            <TextBlock Grid.Row="1" Grid.Column="15"
				HorizontalAlignment="Center"
				Foreground="{StaticResource HeaderColor}"
				Text="Annotations" />

            <Grid Grid.Column="15"
				Margin="5"
				Width="200">

                <Grid.RowDefinitions>
                    <RowDefinition Height="3" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="3" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <!--<TextBlock Grid.Row="1"
					Margin="0,0,3,0" 
					VerticalAlignment="Center" ><Run Text="Text:"/></TextBlock>

                <ComboBox Grid.Row="1" Grid.Column="1"
					IsEditable="True"
					MvvmHelpers:PreviewKeyHelper.CarriageReturnCommand="{Binding MessageSearchCommand}"
					MvvmHelpers:FocusHelper.IsFocused="{Binding IsMessageSearchBoxFocused, Mode=TwoWay}"
					ToolTip="Press Enter to start searching within annotations"
					Text="{Binding MessageSearch, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
					ItemsSource="{Binding Source={StaticResource RecentMessagesSource}}" />
                <Button Command="{Binding MessageSearchCommand}"
					Grid.Column="2" Grid.Row="1">
                    <Image Source="Images/Find16.png" Width="16" Height="16" />
                </Button>-->

                <Button Command="{Binding PreviousAnnotationCommand}"
					Width="75"
					ToolTip="Previous annotation"
					Grid.Column="0" Grid.Row="1">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="Images/Previous16.png" Width="16" Height="16" />
                        <TextBlock Margin="3,0,0,0"><Run Text="Previous"/></TextBlock>
                    </StackPanel>
                </Button>

                <Button Command="{Binding NextAnnotationCommand}"
					Width="75"
					ToolTip="Next annotation"
					Grid.Column="2" Grid.Row="1">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Margin="0,0,10,0"><Run Text="Next"/></TextBlock>
                        <Image Source="Images/Next16.png" Width="16" Height="16" />
                    </StackPanel>
                </Button>
                
                <Button Command="{Binding DeleteAllAnnotationsCommand}"
					HorizontalAlignment="Right"
					Width="75"
					ToolTip="Delete all annotations"
					Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="3">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Margin="0,0,10,0"><Run Text="Clear all"/></TextBlock>
                        <Image Source="Images/Delete16.png" Width="16" Height="16" />
                    </StackPanel>
                </Button>

            </Grid>

        </Grid>

        <!-- Timeline stuff-->
        <Viewbox DockPanel.Dock="Top"
			Height="20"
			Visibility="{Binding TimelineVisibility}"
			Stretch="Fill"
			StretchDirection="Both">

            <Grid Height="20"
				MouseLeftButtonDown="OnMouseLeftButtonDown"
				MouseMove="OnMouseMove"
				MouseLeftButtonUp="OnMouseLeftButtonUp">

                <ContentControl>
                    <mvvmHelpers:TimelineDrawing ItemsSource="{Binding TimelineGroups}" ItemsWidth="{Binding TimelineGroupsWidth}" />
                </ContentControl>

                <Canvas>
                    <Rectangle Canvas.Left="{Binding DragRectangleLeft}" Canvas.Top="0" Width="{Binding DragRectangleWidth}" Height="20"
						ToolTip="{Binding TimelineSelectionExplanation}"
                               >
                        <Rectangle.Fill>
                            <DrawingBrush Viewport="0,0,10,10" ViewportUnits="Absolute"
								TileMode="Tile">
                                <DrawingBrush.Drawing>
                                    <DrawingGroup>
                                        <GeometryDrawing Geometry="M0,0 L10,0 10,10, 0,10Z" Brush="Black"/>
                                        <GeometryDrawing Geometry="M10,10 L20,10 20,20, 10,20Z" Brush="Black" />
                                    </DrawingGroup>
                                </DrawingBrush.Drawing>
                            </DrawingBrush>
                        </Rectangle.Fill>
                    </Rectangle>

                </Canvas>
            </Grid>
        </Viewbox>

        <Grid x:Name="LayoutRoot">
            <Grid.RowDefinitions>
                <!-- 0: body -->
                <RowDefinition Height="*"/>
                <!-- 1: splitter -->
                <RowDefinition Height="Auto" />
                <!-- 2: current message-->
                <RowDefinition Height="{Binding DetailBarHeight, Mode=TwoWay}" />
                <!-- 3: Status bar -->
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <ListView x:Name="_lvLog" 
				mvvmHelpers:CommandHelper.RegisterCommandBindings="{Binding LogCommandBindings}"
				mvvmHelpers:ScrollHelper.ScrollToItem="{Binding LogEntryToShow}"
				SelectionMode="Extended"
				SelectedItem="{Binding SelectedLogEntry, Mode=TwoWay}"
				SelectedIndex="{Binding SelectedLogEntryIndex, Mode=TwoWay}"
				ItemsSource="{Binding DisplayedLogEntries}"
                Style="{DynamicResource LogListViewStyle}"
            >
                <ListView.Resources>
                    <Style TargetType="{x:Type ListViewItem}">
                        <Setter Property="Background" Value="{Binding BackgroundBrush}"/>
                        <Setter Property="Foreground" Value="{Binding ForegroundBrush}"/>
                    </Style>

                    <system:String x:Key="IncludeText"  >Show only '{0}'</system:String>
                    <system:String x:Key="ExcludeText"  >Exclude '{0}'</system:String>
                    <system:String x:Key="HighlightText">Highlight '{0}'</system:String>
                    <system:String x:Key="CopyText"     >Copy '{0}'</system:String>
                </ListView.Resources>


                <ListView.View>
                    <GridView AllowsColumnReorder="False" >

                        <!-- Date -->
                        <GridViewColumn Header="Date" 
                            >
                            <GridViewColumn.Width>
                                <!-- Yes, both the MultiBinding and the first Binding must have the Mode=Two, otherwise the DateColumnWidth is not updated -->
                                <MultiBinding Converter="{StaticResource WidthConverter}" Mode="TwoWay">
                                    <Binding Path="DateColumnWidth" Mode="TwoWay" />
                                    <Binding Path="IsDateShown" />
                                </MultiBinding>
                            </GridViewColumn.Width>

                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <!-- The ContextMenuOpening event handler is there to set the menu data context to the main window view model, 
                                             in order to define all these menu items command at this level instead of within each log entry -->
                                    <TextBlock Text="{Binding DisplayedDay, Mode=OneTime}" 
										ContextMenuOpening="OnListViewContextMenuOpening"
                                        >
                                        <TextBlock.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Command="{Binding CopyDateCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.DisplayedDay, Mode=OneTime, StringFormat={StaticResource CopyText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Copy16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding CopyLineCommand}" 
													      Header="Copy" />
                                                <MenuItem Command="{Binding ExcludeLinesBeforeCommand}"
													      Header="Exclude preceding entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/After16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding ExcludeLinesAfterCommand}" 
													      Header="Exclude following entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Before16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding UpdateAnnotationCommand}" 
													      Header="Annotate...">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Annotate16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding DeleteAnnotationCommand}" 
													      Header="Delete Annotation">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Delete16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                            </ContextMenu>
                                        </TextBlock.ContextMenu>
									</TextBlock>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>

                        <!-- Process -->
                        <GridViewColumn HeaderContainerStyle="{StaticResource LogGridViewColumnHeader}">

                            <!-- Width is dependent on itself + a visibility boolean; if false, the width is 0, as a list view column cannot be hidden -->
                            <GridViewColumn.Width>
                                <MultiBinding Converter="{StaticResource WidthConverter}" Mode="TwoWay">
                                    <Binding Path="ProcessColumnWidth" Mode="TwoWay" />
                                    <Binding Path="IsProcessShown" />
                                </MultiBinding>
                            </GridViewColumn.Width>

                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock d:DataContext="{d:DesignInstance ulsDeobfuscator:LogEntry}"
                                               Text="{Binding Process, Mode=OneTime}"  
                                               ToolTip="{Binding ProcessInformation, Mode=OneTime}"
										       ContextMenuOpening="OnListViewContextMenuOpening">
                                        <TextBlock.ContextMenu>
                                            <ContextMenu d:DataContext="{d:DesignInstance ulsDeobfuscator:MainWindowViewModel}">
                                                <MenuItem Command="{Binding ProcessColumn.IncludeItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Process, Mode=OneTime, StringFormat={StaticResource IncludeText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Ok16.png" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding ProcessColumn.ExcludeItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Process, Mode=OneTime, StringFormat={StaticResource ExcludeText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Nok16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding ProcessColumn.HighlightItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Process, Mode=OneTime, StringFormat={StaticResource HighlightText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Light16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding ProcessColumn.CopyItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Process, Mode=OneTime, StringFormat={StaticResource CopyText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Copy16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding CopyLineCommand}" 
													Header="Copy" />
                                                <MenuItem Command="{Binding ExcludeLinesBeforeCommand}"
													      Header="Exclude preceding entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/After16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding ExcludeLinesAfterCommand}" 
													      Header="Exclude following entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Before16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding UpdateAnnotationCommand}" 
													      Header="Annotate...">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Annotate16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding DeleteAnnotationCommand}" 
													      Header="Delete Annotation">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Delete16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                            </ContextMenu>
                                        </TextBlock.ContextMenu>
									</TextBlock>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>

                            <!-- Header includes the column name + an icon filter in a button -->
                            <Grid HorizontalAlignment="Stretch" x:Name="ProcessHeader">
                                <TextBlock Text="Process" 
									Margin="10,2,0,0" />
                                <Button HorizontalAlignment="Right"
									Command="{Binding ProcessColumn.ShowFilterCommand}"
									Margin="0,0,10,0"
									ToolTip="{Binding ProcessColumn.FilterTooltip}">

                                    <!-- A context menu allows quickly clearing the filter -->
                                    <Button.ContextMenu>
                                        <ContextMenu Visibility="{Binding ProcessColumn.FilterMenuVisibility, Mode=OneWay}">
                                            <MenuItem Header="Clear Process Filter"
												Command="{Binding ProcessColumn.ClearItemFilterCommand}">
                                                <MenuItem.Icon>
                                                    <Image Source="Images/Filter_delete16.png" Width="16" Height="16" />
                                                </MenuItem.Icon>
                                            </MenuItem>
                                        </ContextMenu>
                                    </Button.ContextMenu>
                                    <!-- The actual button image is chosen depending on whether a filter is active or not (same for the tooltip) -->
                                    <Image Source="{Binding ProcessColumn.FilterImagePath}"
										Width="16" Height="16" />
                                </Button>

                                <!-- a popup shows the possible list of items, along with 'select all' / 'select none' buttons, as well as cancel/ok buttons -->
                                <Popup PlacementTarget="{Binding ElementName=ProcessHeader}" 
									Placement="Bottom"
									StaysOpen="False"
									IsOpen="{Binding ProcessColumn.IsShowingItemChoices, Mode=TwoWay}">
                                    <Border BorderThickness="1"
										Background="White" >
                                        <StackPanel>
                                            <!-- Select all / select none -->
                                            <StackPanel Orientation="Horizontal">
                                                <Button Content="All"
													Style="{StaticResource LargeButtonStyle}"
													Margin="5"
													Command="{Binding ProcessColumn.ItemFilterSelectAllCommand}" />
                                                <Button Content="None"
													Margin="5"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding ProcessColumn.ItemFilterSelectNoneCommand}" />

                                            </StackPanel>

                                            <ScrollViewer VerticalScrollBarVisibility="Auto"
												MaxHeight="{Binding ActualHeight, ElementName=_lvLog}">
                                                <!-- The template for the list of choices is in app.xaml -->
                                                <ItemsControl ItemsSource="{Binding Source={StaticResource ProcessesListSource}}" />
                                            </ScrollViewer>

                                            <!-- OK / cancel -->
                                            <Grid HorizontalAlignment="Stretch">
                                                <Button Content="OK"
													Margin="5"
													HorizontalAlignment="Left"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding ProcessColumn.ItemFilterCommand}" />
                                                <Button Content="Cancel"
													Margin="5"
													HorizontalAlignment="Right"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding ProcessColumn.CancelItemFilterCommand}" />

                                            </Grid>
                                        </StackPanel>
                                    </Border>
                                </Popup>
                            </Grid>
                        </GridViewColumn>


                        <!-- Thread Id -->
                        <GridViewColumn Header="Thread ID"
                            >

                            <GridViewColumn.Width>
                                <MultiBinding Converter="{StaticResource WidthConverter}" Mode="TwoWay">
                                    <Binding Path="ThreadIdColumnWidth" Mode="TwoWay" />
                                    <Binding Path="IsThreadIdShown" />
                                </MultiBinding>
                            </GridViewColumn.Width>

                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Tid, Mode=OneTime}" 
										ContextMenuOpening="OnListViewContextMenuOpening"
                                        >
                                        <TextBlock.ContextMenu>
                                            <ContextMenu>
                                                <!-- to be added ? -->
                                                <!--                                                    <MenuItem Command="{Binding IncludeThreadIdCommand}">-->
                                                <!--                                                        <MenuItem.Header>-->
                                                <!--                                                            <TextBlock Text="{Binding SelectedLogEntry.Tid, Mode=OneTime, StringFormat={StaticResource IncludeText}}" />-->
                                                <!--                                                        </MenuItem.Header>-->
                                                <!--                                                        <MenuItem.Icon>-->
                                                <!--                                                            <Image Source="Images/Ok16.png" />-->
                                                <!--                                                        </MenuItem.Icon>-->
                                                <!--                                                    </MenuItem>-->
                                                <!--                                                    <MenuItem Command="{Binding ExcludeThreadIdCommand}">-->
                                                <!--                                                        <MenuItem.Header>-->
                                                <!--                                                            <TextBlock Text="{Binding SelectedLogEntry.Tid, Mode=OneTime, StringFormat={StaticResource ExcludeText}}" />-->
                                                <!--                                                        </MenuItem.Header>-->
                                                <!--                                                        <MenuItem.Icon>-->
                                                <!--                                                            <Image Source="Images/Nok16.png"></Image>-->
                                                <!--                                                        </MenuItem.Icon>-->
                                                <!--                                                    </MenuItem>-->
                                                <!--                                                    <MenuItem Command="{Binding HighlightThreadIdCommand}">-->
                                                <!--                                                        <MenuItem.Header>-->
                                                <!--                                                            <TextBlock Text="{Binding SelectedLogEntry.Tid, Mode=OneTime, StringFormat={StaticResource HighlightText}}" />-->
                                                <!--                                                        </MenuItem.Header>-->
                                                <!--                                                        <MenuItem.Icon>-->
                                                <!--                                                            <Image Source="Images/Light16.png"></Image>-->
                                                <!--                                                        </MenuItem.Icon>-->
                                                <!--                                                    </MenuItem>-->
                                                <MenuItem Command="{Binding CopyThreadIdCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Tid, Mode=OneTime, StringFormat={StaticResource CopyText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Copy16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding CopyLineCommand}" 
        											      Header="Copy" />
                                                <MenuItem Command="{Binding ExcludeLinesBeforeCommand}"
													      Header="Exclude preceding entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/After16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding ExcludeLinesAfterCommand}" 
													      Header="Exclude following entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Before16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding UpdateAnnotationCommand}" 
													      Header="Annotate...">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Annotate16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding DeleteAnnotationCommand}" 
													      Header="Delete Annotation">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Delete16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                            </ContextMenu>
                                        </TextBlock.ContextMenu>
                                            
									</TextBlock>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>

                        </GridViewColumn>


                        <!-- Area -->
                        <GridViewColumn HeaderContainerStyle="{StaticResource LogGridViewColumnHeader}"
                            >

                            <GridViewColumn.Width>
                                <MultiBinding Converter="{StaticResource WidthConverter}" Mode="TwoWay">
                                    <Binding Path="AreaColumnWidth" Mode="TwoWay" />
                                    <Binding Path="IsAreaShown" />
                                </MultiBinding>
                            </GridViewColumn.Width>

                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Area, Mode=OneTime}" 
										ContextMenuOpening="OnListViewContextMenuOpening"
                                        >
                                        <TextBlock.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Command="{Binding AreaColumn.IncludeItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Area, Mode=OneTime, StringFormat={StaticResource IncludeText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Ok16.png" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding AreaColumn.ExcludeItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Area, Mode=OneTime, StringFormat={StaticResource ExcludeText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Nok16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding AreaColumn.HighlightItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Area, Mode=OneTime, StringFormat={StaticResource HighlightText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Light16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding AreaColumn.CopyItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Area, Mode=OneTime, StringFormat={StaticResource CopyText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Copy16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding CopyLineCommand}" 
													Header="Copy" />
                                                <MenuItem Command="{Binding ExcludeLinesBeforeCommand}"
													Header="Exclude preceding entries"
                                                    >
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/After16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding ExcludeLinesAfterCommand}" 
													Header="Exclude following entries"
                                                    >
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Before16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding UpdateAnnotationCommand}" 
													      Header="Annotate...">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Annotate16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding DeleteAnnotationCommand}" 
													      Header="Delete Annotation">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Delete16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                            </ContextMenu>
                                        </TextBlock.ContextMenu>
                                            
									</TextBlock>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                            <Grid HorizontalAlignment="Stretch"
								x:Name="AreaHeader">
                                <TextBlock Text="Area" 
									Margin="10,2,0,0" />
                                <Button HorizontalAlignment="Right"
									Command="{Binding AreaColumn.ShowFilterCommand}"
									ToolTip="{Binding AreaColumn.FilterTooltip}"
									Margin="0,0,10,0"
                                                >

                                    <!-- A context menu allows quickly clearing the filter -->
                                    <Button.ContextMenu>
                                        <ContextMenu Visibility="{Binding AreaColumn.FilterMenuVisibility, Mode=OneWay}">
                                            <MenuItem Header="Clear Area Filter"
												Command="{Binding AreaColumn.ClearItemFilterCommand}">
                                                <MenuItem.Icon>
                                                    <Image Source="Images/Filter_delete16.png" Width="16" Height="16" />
                                                </MenuItem.Icon>
                                            </MenuItem>
                                        </ContextMenu>
                                    </Button.ContextMenu>

                                    <Image Source="{Binding AreaColumn.FilterImagePath}"
										Width="16" Height="16" />

                                </Button>
                                <Popup PlacementTarget="{Binding ElementName=AreaHeader}" 
									Placement="Bottom"
									StaysOpen="False"
									IsOpen="{Binding AreaColumn.IsShowingItemChoices, Mode=TwoWay}">
                                    <Border BorderThickness="1"
										Background="White" >
                                        <StackPanel>
                                            <StackPanel Orientation="Horizontal">
                                                <Button Content="All"
													Style="{StaticResource LargeButtonStyle}"
													Margin="5"
													Command="{Binding AreaColumn.ItemFilterSelectAllCommand}" />
                                                <Button Content="None"
													Margin="5"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding AreaColumn.ItemFilterSelectNoneCommand}" />

                                            </StackPanel>

                                            <ScrollViewer VerticalScrollBarVisibility="Auto"
												MaxHeight="{Binding ActualHeight, ElementName=_lvLog}">
                                                <ItemsControl ItemsSource="{Binding Source={StaticResource AreasListSource}}" />
                                            </ScrollViewer>

                                            <Grid HorizontalAlignment="Stretch">
                                                <Button Content="OK"
													Margin="5"
													HorizontalAlignment="Left"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding AreaColumn.ItemFilterCommand}" />
                                                <Button Content="Cancel"
													Margin="5"
													HorizontalAlignment="Right"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding AreaColumn.CancelItemFilterCommand}" />

                                            </Grid>
                                        </StackPanel>
                                    </Border>
                                </Popup>
                            </Grid>
                        </GridViewColumn>


                        <!-- Category -->
                        <GridViewColumn HeaderContainerStyle="{StaticResource LogGridViewColumnHeader}"
                            >

                            <GridViewColumn.Width>
                                <MultiBinding Converter="{StaticResource WidthConverter}" Mode="TwoWay">
                                    <Binding Path="CategoryColumnWidth" Mode="TwoWay" />
                                    <Binding Path="IsCategoryShown" />
                                </MultiBinding>
                            </GridViewColumn.Width>

                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Category, Mode=OneTime}" 
										ContextMenuOpening="OnListViewContextMenuOpening"
                                        >
                                        <TextBlock.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Command="{Binding CategoryColumn.IncludeItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Category, Mode=OneTime, StringFormat={StaticResource IncludeText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Ok16.png" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding CategoryColumn.ExcludeItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Category, Mode=OneTime, StringFormat={StaticResource ExcludeText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Nok16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding CategoryColumn.HighlightItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Category, Mode=OneTime, StringFormat={StaticResource HighlightText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Light16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding CategoryColumn.CopyItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Category, Mode=OneTime, StringFormat={StaticResource CopyText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Copy16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding CopyLineCommand}" 
													Header="Copy" />
                                                <MenuItem Command="{Binding ExcludeLinesBeforeCommand}"
													      Header="Exclude preceding entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/After16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding ExcludeLinesAfterCommand}" 
													      Header="Exclude following entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Before16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding UpdateAnnotationCommand}" 
													      Header="Annotate...">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Annotate16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding DeleteAnnotationCommand}" 
													      Header="Delete Annotation">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Delete16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                            </ContextMenu>
                                        </TextBlock.ContextMenu>
                                            
									</TextBlock>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                            <Grid HorizontalAlignment="Stretch"
								x:Name="CategoryHeader">
                                <TextBlock Text="Category" 
									Margin="10,2,0,0" />
                                <Button HorizontalAlignment="Right"
									Command="{Binding CategoryColumn.ShowFilterCommand}"
									Margin="0,0,10,0"
									ToolTip="{Binding CategoryColumn.FilterTooltip}">

                                    <!-- A context menu allows quickly clearing the filter -->
                                    <Button.ContextMenu>
                                        <ContextMenu Visibility="{Binding CategoryColumn.FilterMenuVisibility, Mode=OneWay}">
                                            <MenuItem Header="Clear Category Filter"
												Command="{Binding CategoryColumn.ClearItemFilterCommand}">
                                                <MenuItem.Icon>
                                                    <Image Source="Images/Filter_delete16.png" Width="16" Height="16" />
                                                </MenuItem.Icon>
                                            </MenuItem>
                                        </ContextMenu>
                                    </Button.ContextMenu>

                                    <Image Source="{Binding CategoryColumn.FilterImagePath}"
										Width="16" Height="16" />

                                </Button>
                                <Popup PlacementTarget="{Binding ElementName=CategoryHeader}" 
									Placement="Bottom"
									StaysOpen="False"
									IsOpen="{Binding CategoryColumn.IsShowingItemChoices, Mode=TwoWay}">
                                    <Border BorderThickness="1"
										Background="White" >
                                        <StackPanel>
                                            <StackPanel Orientation="Horizontal">
                                                <Button Content="All"
													Style="{StaticResource LargeButtonStyle}"
													Margin="5"
													Command="{Binding CategoryColumn.ItemFilterSelectAllCommand}" />
                                                <Button Content="None"
													Margin="5"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding CategoryColumn.ItemFilterSelectNoneCommand}" />

                                            </StackPanel>

                                            <ScrollViewer VerticalScrollBarVisibility="Auto"
												MaxHeight="{Binding ActualHeight, ElementName=_lvLog}">
                                                <ItemsControl ItemsSource="{Binding Source={StaticResource CategoriesListSource}}" />
                                            </ScrollViewer>

                                            <Grid HorizontalAlignment="Stretch">
                                                <Button Content="OK"
													Margin="5"
													HorizontalAlignment="Left"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding CategoryColumn.ItemFilterCommand}" />
                                                <Button Content="Cancel"
													Margin="5"
													HorizontalAlignment="Right"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding CategoryColumn.CancelItemFilterCommand}" />

                                            </Grid>
                                        </StackPanel>
                                    </Border>
                                </Popup>
                            </Grid>
                        </GridViewColumn>


                        <!-- Event ID -->
                        <GridViewColumn HeaderContainerStyle="{StaticResource LogGridViewColumnHeader}"
                            >

                            <GridViewColumn.Width>
                                <MultiBinding Converter="{StaticResource WidthConverter}" Mode="TwoWay">
                                    <Binding Path="EventIdColumnWidth" Mode="TwoWay" />
                                    <Binding Path="IsEventIdShown" />
                                </MultiBinding>
                            </GridViewColumn.Width>

                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding EventID, Mode=OneTime}" 
										ContextMenuOpening="OnListViewContextMenuOpening"
                                        >
                                        <TextBlock.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Command="{Binding EventColumn.IncludeItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.EventID, Mode=OneTime, StringFormat={StaticResource IncludeText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Ok16.png" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding EventColumn.ExcludeItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.EventID, Mode=OneTime, StringFormat={StaticResource ExcludeText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Nok16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding EventColumn.HighlightItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.EventID, Mode=OneTime, StringFormat={StaticResource HighlightText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Light16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding EventColumn.CopyItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.EventID, Mode=OneTime, StringFormat={StaticResource CopyText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Copy16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding CopyLineCommand}" 
													      Header="Copy" />
                                                <MenuItem Command="{Binding ExcludeLinesBeforeCommand}"
													      Header="Exclude preceding entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/After16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding ExcludeLinesAfterCommand}" 
													      Header="Exclude following entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Before16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding UpdateAnnotationCommand}" 
													      Header="Annotate...">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Annotate16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding DeleteAnnotationCommand}" 
													      Header="Delete Annotation">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Delete16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                            </ContextMenu>
                                        </TextBlock.ContextMenu>
                                            
									</TextBlock>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                            <Grid HorizontalAlignment="Stretch"
								x:Name="EventHeader">
                                <TextBlock Text="Event ID" 
									Margin="10,2,0,0" />
                                <Button HorizontalAlignment="Right"
									Command="{Binding EventColumn.ShowFilterCommand}"
									Margin="0,0,10,0"
									ToolTip="{Binding EventColumn.FilterTooltip}">

                                    <!-- A context menu allows quickly clearing the filter -->
                                    <Button.ContextMenu>
                                        <ContextMenu Visibility="{Binding EventColumn.FilterMenuVisibility, Mode=OneWay}">
                                            <MenuItem Header="Clear Event ID Filter"
												Command="{Binding EventColumn.ItemFilterCommand}">
                                                <MenuItem.Icon>
                                                    <Image Source="Images/Filter_delete16.png" Width="16" Height="16" />
                                                </MenuItem.Icon>
                                            </MenuItem>
                                        </ContextMenu>
                                    </Button.ContextMenu>

                                    <Image Source="{Binding EventColumn.FilterImagePath}"
										Width="16" Height="16" />

                                </Button>
                                <Popup PlacementTarget="{Binding ElementName=EventHeader}" 
									Placement="Bottom"
									StaysOpen="False"
									IsOpen="{Binding EventColumn.IsShowingItemChoices, Mode=TwoWay}">
                                    <Border BorderThickness="1"
										Background="White" >
                                        <StackPanel>
                                            <StackPanel Orientation="Horizontal">
                                                <Button Content="All"
													Style="{StaticResource LargeButtonStyle}"
													Margin="5"
													Command="{Binding EventColumn.ItemFilterSelectAllCommand}" />
                                                <Button Content="None"
													Margin="5"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding EventColumn.ItemFilterSelectNoneCommand}" />

                                            </StackPanel>

                                            <ScrollViewer VerticalScrollBarVisibility="Auto"
												MaxHeight="{Binding ActualHeight, ElementName=_lvLog}">
                                                <ItemsControl ItemsSource="{Binding Source={StaticResource EventsListSource}}"
                                                        />
                                            </ScrollViewer>

                                            <Grid HorizontalAlignment="Stretch">
                                                <Button Content="OK"
													Margin="5"
													HorizontalAlignment="Left"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding EventColumn.ItemFilterCommand}" />
                                                <Button Content="Cancel"
													Margin="5"
													HorizontalAlignment="Right"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding EventColumn.CancelItemFilterCommand}" />
                                            </Grid>
                                        </StackPanel>
                                    </Border>
                                </Popup>
                            </Grid>
                        </GridViewColumn>


                        <!-- Level -->
                        <GridViewColumn HeaderContainerStyle="{StaticResource LogGridViewColumnHeader}"
                            >

                            <GridViewColumn.Width>
                                <MultiBinding Converter="{StaticResource WidthConverter}" Mode="TwoWay">
                                    <Binding Path="LevelColumnWidth" Mode="TwoWay" />
                                    <Binding Path="IsLevelShown" />
                                </MultiBinding>
                            </GridViewColumn.Width>

                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Level, Mode=OneTime}" 
										ContextMenuOpening="OnListViewContextMenuOpening"
                                        >
                                        <TextBlock.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Command="{Binding LevelColumn.IncludeItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Level, Mode=OneTime, StringFormat={StaticResource IncludeText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Ok16.png" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding LevelColumn.ExcludeItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Level, Mode=OneTime, StringFormat={StaticResource ExcludeText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Nok16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding LevelColumn.HighlightItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Level, Mode=OneTime, StringFormat={StaticResource HighlightText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Light16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding LevelColumn.CopyItemCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Level, Mode=OneTime, StringFormat={StaticResource CopyText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Copy16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding CopyLineCommand}" 
													      Header="Copy" />
                                                <MenuItem Command="{Binding ExcludeLinesBeforeCommand}"
													      Header="Exclude preceding entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/After16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding ExcludeLinesAfterCommand}" 
													      Header="Exclude following entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Before16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding UpdateAnnotationCommand}" 
													      Header="Annotate...">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Annotate16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding DeleteAnnotationCommand}" 
													      Header="Delete Annotation">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Delete16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                            </ContextMenu>
                                        </TextBlock.ContextMenu>
                                            
									</TextBlock>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                            <Grid HorizontalAlignment="Stretch"
								x:Name="LevelHeader">
                                <TextBlock Text="Level" 
									Margin="10,2,0,0" />
                                <Button HorizontalAlignment="Right"
									Command="{Binding LevelColumn.ShowFilterCommand}"
									Margin="0,0,10,0"
									ToolTip="{Binding LevelColumn.FilterTooltip}"
                                                >

                                    <!-- A context menu allows quickly clearing the filter -->
                                    <Button.ContextMenu>
                                        <ContextMenu Visibility="{Binding LevelColumn.FilterMenuVisibility, Mode=OneWay}">
                                            <MenuItem Header="Clear Level Filter"
												Command="{Binding LevelColumn.ClearItemFilterCommand}">
                                                <MenuItem.Icon>
                                                    <Image Source="Images/Filter_delete16.png" Width="16" Height="16" />
                                                </MenuItem.Icon>
                                            </MenuItem>
                                        </ContextMenu>
                                    </Button.ContextMenu>

                                    <Image Source="{Binding LevelColumn.FilterImagePath}"
										Width="16" Height="16" />

                                </Button>
                                <Popup PlacementTarget="{Binding ElementName=LevelHeader}" 
									Placement="Bottom"
									StaysOpen="False"
									IsOpen="{Binding LevelColumn.IsShowingItemChoices, Mode=TwoWay}">
                                    <Border BorderThickness="1"
										Background="White" >
                                        <StackPanel>
                                            <StackPanel Orientation="Horizontal">
                                                <Button Content="All"
													Style="{StaticResource LargeButtonStyle}"
													Margin="5"
													Command="{Binding LevelColumn.ItemFilterSelectAllCommand}" />
                                                <Button Content="None"
													Margin="5"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding LevelColumn.ItemFilterSelectNoneCommand}" />

                                            </StackPanel>

                                            <ScrollViewer VerticalScrollBarVisibility="Auto"
												MaxHeight="{Binding ActualHeight, ElementName=_lvLog}">
                                                <ItemsControl ItemsSource="{Binding Source={StaticResource LevelsListSource}}" />
                                            </ScrollViewer>

                                            <Grid HorizontalAlignment="Stretch">
                                                <Button Content="OK"
													Margin="5"
													HorizontalAlignment="Left"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding LevelColumn.ItemFilterCommand}" />
                                                <Button Content="Cancel"
													Margin="5"
													HorizontalAlignment="Right"
													Style="{StaticResource LargeButtonStyle}"
													Command="{Binding LevelColumn.CancelItemFilterCommand}" />

                                            </Grid>
                                        </StackPanel>
                                    </Border>
                                </Popup>
                            </Grid>
                        </GridViewColumn>


                        <!-- Message -->
                        <GridViewColumn Header="Message"
                            >
                            <GridViewColumn.Width>
                                <MultiBinding Converter="{StaticResource WidthConverter}" Mode="TwoWay">
                                    <Binding Path="MessageColumnWidth" Mode="TwoWay" />
                                    <Binding Path="IsMessageShown" />
                                </MultiBinding>
                            </GridViewColumn.Width>

                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Message, Mode=OneTime}"
										TextWrapping="NoWrap" 
										ContextMenuOpening="OnListViewContextMenuOpening"
                                        >
                                        <TextBlock.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Command="{Binding CopyMessageCommand}"
													Header="Copy message">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Copy16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding CopyLineCommand}" 
													Header="Copy" />
                                                <MenuItem Command="{Binding ExcludeLinesBeforeCommand}"
													      Header="Exclude preceding entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/After16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding ExcludeLinesAfterCommand}" 
													      Header="Exclude following entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Before16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding UpdateAnnotationCommand}" 
													      Header="Annotate...">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Annotate16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding DeleteAnnotationCommand}" 
													      Header="Delete Annotation">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Delete16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                            </ContextMenu>
                                        </TextBlock.ContextMenu>

                                    </TextBlock>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>


                        <!-- Correlation -->
                        <GridViewColumn Header="Correlation ID"
                            >
                            <GridViewColumn.Width>
                                <MultiBinding Converter="{StaticResource WidthConverter}" Mode="TwoWay">
                                    <Binding Path="CorrelationColumnWidth" Mode="TwoWay" />
                                    <Binding Path="IsCorrelationShown" />
                                </MultiBinding>
                            </GridViewColumn.Width>

                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Correlation, Mode=OneTime}" 
										ContextMenuOpening="OnListViewContextMenuOpening"
                                        >
                                        <TextBlock.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Command="{Binding IncludeCorrelationCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Correlation, Mode=OneTime, StringFormat={StaticResource IncludeText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Ok16.png" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding HighlightCorrelationCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Correlation, Mode=OneTime, StringFormat={StaticResource HighlightText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Light16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding CopyCorrelationCommand}">
                                                    <MenuItem.Header>
                                                        <TextBlock Text="{Binding SelectedLogEntry.Correlation, Mode=OneTime, StringFormat={StaticResource CopyText}}" />
                                                    </MenuItem.Header>
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Copy16.png"/>
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding CopyLineCommand}" 
													      Header="Copy" />
                                                <MenuItem Command="{Binding ExcludeLinesBeforeCommand}"
													      Header="Exclude preceding entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/After16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding ExcludeLinesAfterCommand}" 
													      Header="Exclude following entries">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Before16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <Separator />
                                                <MenuItem Command="{Binding UpdateAnnotationCommand}" 
													      Header="Annotate...">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Annotate16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                                <MenuItem Command="{Binding DeleteAnnotationCommand}" 
													      Header="Delete Annotation">
                                                    <MenuItem.Icon>
                                                        <Image Source="Images/Delete16.png" Width="16" Height="16" />
                                                    </MenuItem.Icon>
                                                </MenuItem>
                                            </ContextMenu>
                                        </TextBlock.ContextMenu>
                                            
									</TextBlock>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>

            <GridSplitter Grid.Row="1"
				Style="{StaticResource HorizontalGridSplitter}"
				ResizeDirection="Rows"
				ResizeBehavior="PreviousAndNext"
				HorizontalAlignment="Stretch"
				VerticalAlignment="Center" />

            <TextBox TextWrapping="Wrap"
				Grid.Row="2" 
				IsReadOnly="True"
				VerticalAlignment="Stretch"
				Text="{Binding SelectedItem.ParsedMessage, ElementName=_lvLog, Mode=OneWay}"
				markup:TextBoxHelper.SelectedText="{Binding ParsedMessageSelectedText, Mode=TwoWay}" >
                <TextBox.ContextMenu>
                    <ContextMenu >
                        <MenuItem Header="Copy"
							Command="{Binding CopyTextCommand}">
                            <MenuItem.Icon>
                                <Image Source="Images/Copy16.png" Width="16" Height="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <MenuItem Header="Search online..."
							Command="{Binding SearchTextCommand}">
                            <MenuItem.Icon>
                                <Image Source="Images/Google16.png" Width="16" Height="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                    </ContextMenu>
                </TextBox.ContextMenu>
            </TextBox>

            <StatusBar Grid.Row="3" >
                <StatusBarItem HorizontalContentAlignment="Stretch">
                    <Grid HorizontalAlignment="Stretch">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0"
							Text="{Binding Status}"
							TextWrapping="NoWrap" 
							TextTrimming="CharacterEllipsis" />

                        <TextBlock Grid.Column="1"
							Margin="10,0,10,0"
							Text="{Binding LineInformation}"
							TextWrapping="NoWrap" 
							TextTrimming="CharacterEllipsis" />

                        <TextBlock Grid.Column="2"
							Text="{Binding DisplayedFilesList}"
							TextWrapping="NoWrap" 
							TextTrimming="CharacterEllipsis" />

                    </Grid>
                </StatusBarItem>
            </StatusBar>

            <Popup IsOpen="{Binding IsShowingDropDialog}"
				Placement="MousePoint" 
				StaysOpen="False">
                <Border BorderThickness="1"
					Background="White">
                    <StackPanel Margin="5">
                        <TextBlock Text="{Binding FilesDropCount, StringFormat=Opening \{0\} file(s)}"/>
                        <Button Command="{Binding DropReplaceFilesCommand}"
							Margin="0,5,0,5" Content="_Replace existing log display"/>
                        <Button Command="{Binding DropAddFilesCommand}" Content="_Add to existing log display"/>
                        <TextBlock Margin="0,5,0,0"><Run Text="Tip: you can bypasss this dialog."/></TextBlock>
                        <TextBlock><Run Text="Hold Shift to replace the log display, or."/></TextBlock>
                        <TextBlock><Run Text="Hold Control to add the dragged files."/></TextBlock>
                    </StackPanel>
                </Border>
            </Popup>
        </Grid>
    </DockPanel>

</mvvmHelpers:SystemMenuWindow>
